from flask import Blueprint, request
from utilsapp.mysql_con import db_pagelist, db_fetchone, db_delete, db_update,db_insert ,db_fetchall
from utilsapp.common import assign_value, parsing_data_id,get_operate
import json
bluePrint = Blueprint('algorithm_model', __name__)
tableName = 'algorithm_model'


# 分页查询
@bluePrint.route('/getlist', methods=["post"])
def getlist():
    a = request.json
    scope_id = assign_value(a, "scope_id", 0)
    scoped = parsing_data_id(scope_id, request)
    m_desc = assign_value(a, "m_desc")
    query = ""
    # if scoped != "":
        # query += f" and {scoped}"
    if m_desc != "":
        query += f" and m_desc like '%{m_desc}%'"
    sql = f"select * from {tableName} where 1=1 {query} ORDER BY m_m_code"
    res = db_pagelist(sql, a['page'], a['size'])
    return res